import Vue from 'vue'
import Router from 'vue-router'
import Login from '../page/Login.vue'
import Register from '../page/Register.vue'
import SmscodeLogin from '../page/SmscodeLogin.vue'
import ForgetPassword from '../page/ForgetPassword.vue'
import UserAgreement from '../page/UserAgreement.vue'
import PrivacyPolicy from '../page/PrivacyPolicy.vue'
import BindPhoneLogin from '../page/BindPhoneLogin.vue'

Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/',
      component: Login,
      name: 'login',
      meta: {
        title: ''
      }
    },
    {
      path: '/login/register',
      component: Register,
      name: 'register',
      meta: {
        keepAlive: true,
        title: '注册账号'
      }
    },
    {
      path: '/login/smscodeLogin',
      component: SmscodeLogin,
      name: 'smscodeLogin',
      meta: {
        title: '验证码登录'
      }
    },
    {
      path: '/login/forgetPassword',
      component: ForgetPassword,
      name: 'forgetPassword',
      meta: {
        title: '忘记密码'
      }
    },
    {
      path: '/bindPhoneLogin',
      component: BindPhoneLogin,
      name: 'bindPhoneLogin',
      meta: {
        keepAlive: true,
        title: '绑定手机号'
      }
    },
    {
      path: '/agreement',
      component: UserAgreement,
      name: 'agreement',
      meta: {
        title: '用户协议'
      }
    },
    {
      path: '/privacyPolicy',
      component: PrivacyPolicy,
      name: 'privacyPolicy',
      meta: {
        title: '隐私政策'
      }
    }
  ]
})
// router.beforeEach((to, from, next) => {
//   console.log('~~~from.path', from.path)
//   console.log('~~~to.path', to.path)
//   let path = '/'
//   if (path === to.path) {
//     router.replace({ path: 'homepage' })
//   }
//   next()
// })
export default router
